﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFControls
{
	/// <summary>
	/// DrowdownMenuItem.xaml 的交互逻辑
	/// </summary>
	public partial class DrowdownMenuItem : UserControl
	{
		public DrowdownMenuItem()
		{
			this.InitializeComponent();
		}

        public string XImageSource
        {
            set
            {
                this.icon.Source = new BitmapImage(new Uri(value, UriKind.RelativeOrAbsolute));
            }
            get
            {
                return this.icon.Source.ToString();
            }
        }

        public string XText
        {
            set
            {
                this.itemText.Text = value;
            }
            get
            {
                return this.itemText.Text;
            }
        }

        public event MouseButtonEventHandler XClick;

        private void mouseCapture_MouseEnter(object sender, MouseEventArgs e)
        {
            this.mouseCapture.Opacity = 0.5;
        }

        private void mouseCapture_MouseLeave(object sender, MouseEventArgs e)
        {
            this.mouseCapture.Opacity = 0;
        }

        private void mouseCapture_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (XClick != null)
            {
                XClick.Invoke(sender, e);
            }
        }        
	}
}